/*
 * Neusoft Corporation Copyright 2015-2025, All rights reserved.
 * �ļ���  :PropertiesUtils.java
 * ������  :Magic_yuan
 * ����ʱ��:2015��5��11��
 */

package com.magicyuan.search.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * [简要描述]:<br/>
 * [详细描述]:<br/>
 * 
 * @version [revision],2015年5月20日
 */
public class PropertiesUtils {
	public static Properties getProperties() {
		Properties prop = new Properties();

		try {
			prop.load(
					new FileInputStream(PropertiesUtils.class.getResource("/").getPath() + "searchConfig.properties"));
			System.out.println(PropertiesUtils.class.getResource("/").getPath() + "searchConfig.properties");
		} catch (IOException e) {
			e.printStackTrace();
		}

		return prop;
	}

	public static String getValue(String key) {
		return PropertiesUtils.getProperties().getProperty(key);
	}

	public static void setValue(String key, String value) {
		Properties properties = getProperties();

		try {
			File file = new File(PropertiesUtils.class.getResource("/").getPath() + "wxConfig.properties");
			FileOutputStream outStream = new FileOutputStream(file);
			properties.setProperty(key, value);
			// 写入properties文件
			properties.store(outStream, null);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
